include( 'shared.lua' )

function GM:Initialize( )	

	self.BaseClass:Initialize()
	GAMEMODE:SetupTeams()
	timer.Create( "Timer_UpdateNetworkVars", 1, 0, UpdateNetworkVars ) 	
end


function GM:Think()

end	



function DrawBox()
	local width = ScrW() / 3
	local freezePer = width - (( TIME_FREEZE_BOMB / TIME_FREEZE_BOMB_MAX ) * width )
	local roundPer =  width - (( TIME_ROUND / TIME_ROUND_MAX ) * width )
	draw.RoundedBox( 10, 0, 0, width, 50, Color(0, 0, 0, 100) );
	local bev = 10
	if roundPer < 20 then bev = roundPer / 2 else bev = 10 end
	draw.RoundedBox( bev, 0, 0, roundPer, 25, Color(255, 0, 0, 100) );
	if freezePer < 20 then bev = freezePer / 2 else bev = 10 end
	draw.RoundedBox( bev, 0, 25, freezePer, 25, Color(0, 0, 255, 100) );
	draw.DrawText("Round:"..TIME_ROUND, "ScoreboardText", 10, 5, Color(0,0,0,200),0)
	draw.DrawText("Freeze Bomb:"..TIME_FREEZE_BOMB, "ScoreboardText", 10, 30, Color(0,0,0,200),0)	
	if WIN != 0 then
		DrawWin( WIN )
	end
end
hook.Add("HUDPaint", "DrawBox", DrawBox); 



function DrawWin( winningTeam )
	local winText = ""
	local winColor = Color(0,0,0,200)
	if winningTeam == TEAM_IT then
		winText = "IT WINS !!!"
		winColor = Color(255,0,0,200)
	else
		winText = "NOT IT WINS !!!"
		winColor = Color(0,0,255,200)
	end
	
	surface.CreateFont( "ScoreboardText", 100, 1000, false, false, "MyWinningFont" )  
	draw.DrawText(winText, "MyWinningFont", ScrW() / 2 , ScrH() / 2, winColor,1)	
end



function UpdateNetworkVars() 
	local fbt = GetGlobalInt( "TIME_FREEZE_BOMB")
	if fbt != nil then TIME_FREEZE_BOMB = fbt end 
	local tr = GetGlobalInt( "TIME_ROUND")
	if tr != nil then TIME_ROUND = tr end 
	local isWin = GetGlobalInt( "WIN")
	if isWin != nil then WIN = isWin end 
end 




